#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Cisco::ShowIpOspfNeighbor < Aio::Module::Cmd::Cisco
	include Aio::Module

	def initialize
		super({
			:cmd_full			=> "show ip ospf neighbor",
			:cmd_short		=> "sh ip o n",
			:author				=> "Elin",
			:description	=> "This is Cisco Command# show ip ospf neighbor",
			:ranking			=> Ranking_1,
			:platform			=> "all",
		})
	end

	def parse
		context = self.context.dup
		useful[:ospf_neighbor] = {}
		context.readline_match_block(/Neighbor ID/) {|b|b}
		count = 0
		context.readline_match_block_loop(/(?<neighbor_id>[^\s]+) (?<pri>\d+) (?<state>[^\s]+) (.*) (?<address>[^\s]+) (?<interface>.*)/, reg_blank) do |block|
			nei = {}
			nei_id = block[:neighbor_id]
			useful[:ospf_neighbor][nei_id.to_sym] = nei
			block.update(nei, :neighbor_id)
			block.update(nei, :pri)
			block.update(nei, :state)
			block.update(nei, :address)
			block.update(nei, :interface)
			count += 1
		end
	end
end

			
